<?php
class site_k_office extends ss_konstrukt_detail_component {
	protected $templates;
	protected $structureMapper;
	protected $entryMapper;
	protected $strucure;
	protected $node;
	protected $office;
	
	public function __construct($ss_settings,site_templatefactory $templates, site_dao_structure_mapper $structureMapper){
		$this->structureMapper=$structureMapper;
		$this->structure=$structureMapper->api_master();
    	$this->templates = $templates;
		$this->settings=$ss_settings;
	}
	
	public function dispatch(){
		$this->node=$this->structure->getNodeFromSlug($this->name());
		$this->office=$this->context->getOfficeByConnection($this->node->primary());
		//$this->offices= $this->injector()->create('site_dao_office_mapper')->officeByID();
		//$this->node=$this->structure->getNodeFromSlug($this->name());
		//$this->document->setTitle("Structure ".$this->node->headline());
		ss_error::log('Office dispatch');
		//$this->entries=$this->entryMapper->getEntriesByCategorySlug($this->name());
		//ss_error::log($this->node->primary(),'ID');
		return parent::dispatch();
	}
	
	public function office(){
		return $this->office;
	}
	
	public function map($name){
		ss_error::log($name,'Mapping office');
		if($name==$this->settings->server->appath->staff) return 'site_k_officeStaffList';
	}
	
	public function GET(){
		ss_error::log('Office GET');
		$this->content=$this->office->getData();
		return parent::GET();
	}
	
	protected function renderHtml() {
    	$smarty = $this->templates->create();
	    $smarty->assign('content', $this->content);
		$smarty->register_object('ss_path', $this->settings->server->appath);
	    $smarty->assign('context', $this);
    	return $smarty->fetch("office.tpl");
	}
}
?>